<?php

namespace App\Admin\Actions\VisitWebTask;

use App\Models\VisitLog;
use App\Models\VisitWebTask;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class Retry extends RowAction
{
    public $name = '重试';

    public function handle(Model $model)
    {
        // $model ...
        $model->status = VisitWebTask::STATUS_RETRY;
        $model->save();
        return $this->response()->success('Success message.')->refresh();
    }
    // 这个方法来根据`star`字段的值来在这一列显示不同的图标
    public function display($status)
    {
        if(in_array($status,[VisitWebTask::STATUS_PULLED,VisitWebTask::STATUS_DONE])){
            return "重试";
        }
        return  VisitWebTask::STATUS_VALUE[$status];
    }
}
